const {
  querySql,
  updateSql,
  insertSql,
  deleteSql,
  queryOne,
} = require("../db");

function getExaminationList(query) {
  const { semesterId, type } = query;
  return querySql(
    `select fix_data.*,
    classroom_list.roomName,
    classroom_list.roomCode,
    classroom_list.space from fix_data left join classroom_list on fix_data.classroomId  = classroom_list.id where semesterId = ${semesterId} and type = ${type}`
  );
}

function editExamination(query) {
  return updateSql(query, "fix_data", `where id = ${query.id}`);
}

function createExamination(query) {
  return insertSql(query, "fix_data");
}

function deleteExamination(query) {
  return deleteSql("id", query.id, "fix_data");
}

module.exports = {
  getExaminationList,
  getTotalCount,
  editExamination,
  createExamination,
  deleteExamination,
};
